<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Design extends MY_Controller {

    var $_templates = array();
    var $_lang = '';

    function __construct() {
        parent::__construct();
        $this->session->set_userdata(array('Url' => uri_string()));
        
        $this->_lang = $this->lang->lang();
        $this->load->library('string_library');
        $this->load->model('staticpage_model', 'staticpage');
        $this->load->model('product_model', 'products');
		$this->load->model('design_model', 'design');
		$this->load->model('staticpage_model', 'staticpage');
		 
    }

    public function index($type="woman") {
        $this->_templates['page'] = 'design/index';
        $str_alias = $this->uri->uri_string();
        $this->_data['tab'] = $type;
        $this->_data['listproductItems'] = $this->products->getProducts(array('bl_active' => 1), "viewed DESC", 20, 0);
		$this->_data['trendyItem'] = $this->staticpage->getStaticByAlias('trendy');
        $this->_data['pageTitle'] = "ngoinhabeyeu.com - Website mua sắm thời trang hàng hiệu trực tuyến hàng đầu Việt Nam";
        $this->site_lib->load($this->_templates['page'], $this->_data);
    }
    
    public function save() {
        $json = array();
		$type = $this->input->post('type');
		$product_code = $this->input->post('product_code');
		$vai = $this->input->post('vai');
		$dai_tay = $this->input->post('dai_tay');
		$dai_ao = $this->input->post('dai_ao');
		$bap_tay = $this->input->post('bap_tay');
		$vong_nguc = $this->input->post('vong_nguc');
		$vong_eo = $this->input->post('vong_eo');
		$vong_mong = $this->input->post('vong_mong');
		$vong_co = $this->input->post('vong_co');
		$ds_full_name = $this->input->post('ds_full_name');
		$ds_email = $this->input->post('ds_email');
		$ds_telephone = $this->input->post('ds_telephone');
		$ds_address = $this->input->post('ds_address');
		$dt_create = date('Y-m-d H:i:s') ;
		$data=array('type'=>$type,'code'=>$product_code,'vai'=>$vai,'dai_tay'=>$dai_tay,'dai_ao'=>$dai_ao,'bap_tay'=>$bap_tay,'vong_nguc'=>$vong_nguc,'vong_eo'=>$vong_eo,'vong_mong'=>$vong_mong,'vong_co'=>$vong_co,'full_name'=>$ds_full_name,'phone'=>$ds_telephone,'address'=>$ds_address,'email'=>$ds_email,'bl_active'=>1,'dt_create'=>$dt_create);
		if($this->design->saveDesign($data)){
        $json['status'] = true;
		}else{
			$json['status'] = false;
		}
        echo json_encode($json);
        exit;
    }

}